<!DOCTYPE html>
<html>
<head>
    <title>模具维修详情</title>
    #parse("sys/header.html")
    <style>
        .ivu-row {
            padding-bottom: 0px 20px;
        }
    </style>
</head>
<body>
<div id="rrapp" v-cloak>
    <i-form ref="formValidate" :label-width="100" style="margin: 20px">
        <Row>
            <i-col span="12">
                <Form-item label="模具号">
                    <i-input v-model="moduleRepairRocord.moduleNo" readonly></i-input>
                </Form-item>
            </i-col>
            <i-col span="12">
                <Form-item label="设备名称">
                    <i-input v-model="moduleRepairRocord.devName" readonly></i-input>
                </Form-item>
            </i-col>
        </Row>
        <Row>
            <i-col span="12">
                <Form-item label="报修编号">
                    <i-input v-model="moduleRepairRocord.repairCode" readonly></i-input>
                </Form-item>
            </i-col>
            <i-col span="12">
                <Form-item label="报修时间">
                    <i-input v-model="moduleRepairRocord.repairDate" readonly></i-input>
                </Form-item>
            </i-col>
        </Row>
        <Row>
            <i-col span="12">
                <Form-item label="故障代码">
                    <i-input v-model="moduleRepairRocord.faultCode" readonly></i-input>
                </Form-item>
            </i-col>
            <i-col span="12">
                <Form-item label="故障描述">
                    <i-input v-model="moduleRepairRocord.faultDesc" readonly></i-input>
                </Form-item>
            </i-col>
        </Row>
        <Row>
            <i-col span="12">
                <Form-item label="上报人">
                    <i-input v-model="moduleRepairRocord.report" readonly></i-input>
                </Form-item>
            </i-col>
            <i-col span="12">
                <Form-item label="维修人">
                    <i-input v-model="moduleRepairRocord.orderExecuteUsername" readonly></i-input>
                </Form-item>
            </i-col>
        </Row>
        <Row>
            <i-col span="12">
                <Form-item label="开始维修时间" prop="orderExecuteDate">
                    <Date-picker v-model="moduleRepairRocord.orderExecuteDate" type="datetime" placeholder="开始维修时间" readonly></Date-picker>
                </Form-item>
            </i-col>
            <i-col span="6">
                <Form-item label="结束维修时间" prop="orderEndDate">
                    <Date-picker v-model="moduleRepairRocord.orderEndDate" type="datetime" placeholder="结束时间" readonly></Date-picker>
                </Form-item>
            </i-col>
            <i-col span="6">
                <Form-item label="恢复时间" prop="resumeProductionTime">
                    <Date-picker v-model="moduleRepairRocord.resumeProductionTime" type="datetime" placeholder="恢复时间" readonly></Date-picker>
                </Form-item>
            </i-col>
        </Row>
        <Row>
            <i-col span="12">
                <Form-item label="故障描述" prop="recordDescr">
                    <i-input type="textarea" v-model="moduleRepairRocord.recordDescr" placeholder="故障描述"
                             readonly></i-input>
                </Form-item>
            </i-col>
            <i-col span="12">
                <Form-item label="解决方案" prop="solution">
                    <i-input type="textarea" v-model="moduleRepairRocord.solution" placeholder="解决方案"
                             readonly></i-input>
                </Form-item>
            </i-col>
        </Row>
        <Row>
            <i-col span="12">
                <Form-item label="备注" prop="remark">
                    <i-input type="textarea" v-model="moduleRepairRocord.remark" placeholder="备注" readonly></i-input>
                </Form-item>
            </i-col>
        </Row>
    </i-form>
    <Card>
        <Tabs value="name0" type="card">
            <Tab-pane label="换件记录" name="name0">
                <table id="jqGrid0"></table>
            </Tab-pane>
        </Tabs>
    </Card>
</div>
<script>
    // 模具紧急维护报修记录ID
    var repairId = getQueryString("repairId");
    // 模具紧急维护报修编号
    var repairCode = getQueryString("repairCode");
    $(function () {
        vm.getInfo(repairId);
        $("#jqGrid0").Grid({
            url: '../modulereplacepart/list?&replaceCode=' + repairCode,
            height: 300,
            rowNum: 10,
            rowList: [10, 20, 30],
            rownumWidth: 35,
            multiselect: false,
            colModel: [
                {label: '模具编码', name: 'moduleCode', index: 'MODULE_CODE', width: 80},
                {label: '模具备件名称', name: 'fittingName', index: 'FITTING_NAME', width: 80},
                {
                    label: '更换时间', name: 'replaceDate', index: 'REPLACE_DATE', width: 80, formatter: function (value) {
                        return transDate(value, 'yyyy-MM-dd');
                    }
                },
                {label: '使用模次', name: 'useTime', index: 'USE_TIME', width: 80},
                {label: '寿命标准', name: 'lifeStandard', index: 'LIFE_STANDARD', width: 80},
                {label: '实际使用次数', name: 'realUseTime', index: 'REAL_USE_TIME', width: 80},
                {label: '类型', name: 'type', index: 'TYPE', width: 80},
                {label: '备注信息', name: 'remark', index: 'REMARK', width: 80},
                {label: 'id', name: 'id', index: 'ID', key: true, hidden: true},
            ]
        });
    });
    var vm = new Vue({
        el: '#rrapp',
        data: {
            showList: true,
            title: null,
            q1: {
                useTeam: ''
            },
            moduleTypeList: enumsToList('MODULE_SPAREPART'), //模具 备件更换 镶块、型芯、镶件
            moduleRepairRocord: {
                updateDate: '',
                updateUser: '',
                createDate: '',
                createUser: '',
                delFlag: '',
                useTeam: '',
                isError: '',
                checkDate: '',
                resultCheckUser: '',
                resultCheck: '',
                dealMethod: '',
                orderAcceptDate: '',
                orderExecuteDate: '',
                taskDate: '',
                orderExecuteUser: '',
                approveDate: '',
                approveUser: '',
                approveDeal: '',
                isUrge: '',
                status: '',
                repairDate: '',
                faultDes: '',
                faultType: '',
                faultCode: '',
                report: '',
                moduleNo: '',
                repairCode: '',
                workshop: '',
                id: '',
                isWait: '',
                subShop: ''
            },
            loading: false,
            moldList: [] // 根据模具号查询的模具列表
        },
        methods: {
            filterMethod(value, option) {
                return option.toUpperCase().indexOf(value.toUpperCase()) !== -1;
            },
            getInfo: function (id) {
                Ajax.request({
                    url: "../modulerepairrocord/info/" + id,
                    async: false,
                    successCallback: function (r) {
                        vm.moduleRepairRocord = r.moduleRepairRocord;
                    }
                });
            },
            doRemoteMoldSearch: function (value) {
                if (!value || value.length < 4) {
                    return;
                }
                Ajax.request({
                    url: "../modulearchives/listAll?moduleNo=" + value,
                    async: false,
                    successCallback: function (r) {
                        vm.moldList = r.list;
                    }
                });
            },
            // 调整维修日时，针对派工时间、开始维修时间、结束维修时间、效果确认时间、添加维修记录时间进行修改
            adjustRepairDateTime: function () {
                // 调整维修时间格式
                if (vm.moduleRepairRocord.repairDate) {
                    vm.moduleRepairRocord.repairDate = gmt2DateTimeStr(vm.moduleRepairRocord.repairDate);
                }
                if (vm.moduleRepairRocord.orderExecuteDate) {
                    vm.moduleRepairRocord.orderExecuteDate = gmt2DateTimeStr(vm.moduleRepairRocord.orderExecuteDate);
                }
                if (vm.moduleRepairRocord.orderEndDate) {
                    vm.moduleRepairRocord.orderEndDate = gmt2DateTimeStr(vm.moduleRepairRocord.orderEndDate);
                }
                Ajax.request({
                    url: '../modulerepairrocord/update',
                    params: JSON.stringify(vm.moduleRepairRocord),
                    type: "POST",
                    contentType: "application/json",
                    successCallback: function (r) {
                        iview.Message.success('更新成功');
                    }
                });
            }
        }
    });

    function dateFtt(dateStr) {
        if (dateStr != null && dateStr != "null") {
            var date = new Date(dateStr);//当前时间
            var month = zeroFill(date.getMonth() + 1);//月
            var day = zeroFill(date.getDate());//日
            var hour = zeroFill(date.getHours());//时
            var minute = zeroFill(date.getMinutes());//分
            var second = zeroFill(date.getSeconds());//秒
            //当前时间
            var curTime = date.getFullYear() + "-" + month + "-" + day
                + " " + hour + ":" + minute + ":" + second;
            return curTime;
        }
    }
</script>
</body>
</html>
